package com.qf.ability.auth.service.auth;

import com.qf.ability.auth.entity.AuthInfo;
import com.qf.ability.auth.service.IAuthService;
import com.qf.business.user.feign.WxUserFeign;
import com.qf.commons.data.base.BaseUser;
import com.qf.data.user.entity.WxUser;
import com.qf.data.user.vo.input.WxUserInput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("authService2")
public class WxAuthServiceImpl implements IAuthService {

    @Autowired
    private WxUserFeign wxUserFeign;

    @Override
    public BaseUser login(AuthInfo authInfo) {
        //调用用户服务 获取小程序的用户信息
        WxUser wxUser = (WxUser) wxUserFeign.queryWxUser(new WxUserInput()
                .setCode(authInfo.getWxCode())
                .setHeader(authInfo.getHeader())
                .setNickname(authInfo.getNickname())).getData();

        return wxUser;
    }
}